<?php
if (!defined('ROOT_PATH')) die('No direct access.');
	if ((isset($param[2])) && (isset($param[3])) && ($param[1]=='a')) view_barang($param[2]);
	else if (isset($param[1])){
		if (isset($_SESSION['logged'])){
			switch ($param[1]){
				case 'edit' :
					if (isset($_POST['ubah'])){
						//submit
						$nama = $_POST['nama-barang'];
						$berat = $_POST['berat-barang'];
						$harga = $_POST['harga-barang'];
						$pre = $_POST['pre-order'];
						$kategori = $_POST['kategori'];
						$desc = $_POST['desc-barang'];
						$tag = $_POST['tag-barang'];
						$id = $_POST['idbarang'];
						editBarang($id,$nama,$berat,$harga,$desc,$pre,$tag,$kategori);
						header('Location: ' . $_SERVER['HTTP_REFERER']);	//redirect ke halaman sebelumnya
					}
					break;
				default:
					view_404();
					break;
			}
	}else
		view_404();
	}
?>

